// xc_lshop/shop/user/balance/details.js
var actmember = require('../../../../xc/model/member')

Page({
  mixins: [require('../../../../xc/mixins/basicMixin')],

  /**
   * 页面的初始数据
   */
  data: {
    
  },
  xcloaddata: function (options, config) {
    var that=this;
    if(config.task){
       this.setData({
        taskconfig:config.task
       })
    }
    this.getpagelist(that, 1)
    // if (config.prothem) {
    //   if (config.prothem.themcolor) {
    //     this.setData({
    //       themconfig:config.prothem.themcolor.config
    //     })
    //     // console.log(config.prothem.themcolor)
    //     // var themconfig = config.prothem.themcolor.config;
    //     // updatedata['themconfig'] = themconfig
    //   }
    // }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  getpagelist(that, rest, strwhere) {
    if (rest == 1) {
      if (!strwhere) {
        strwhere = {};
      }
      strwhere["status"] = 1;
      // strwhere["isout"] = this.data.actpid;
      // strwhere["spid"] = this.data.actspid;
      // strwhere["seachval"] = this.data.seachval;
      that.setData({ modellist: [] });
    }
    actmember.coinoffset(that, rest, strwhere).then(function (result) {
      var updatemdoel = {};

      if ((result["code"] == "over" && result["obj"]) || result["code"] == "loadmore") {

        //  for(var a in result["obj"]["modellist"] ){
        //    if(result["obj"]["modellist"][a]){
        //     result["obj"]["modellist"][a]["snapshot"] = JSON.parse(result["obj"]["modellist"][a]["snapshot"])
        //    }
        //  }     
        if (rest == 1) {
          updatemdoel["modellist"] = result["obj"]["modellist"];
        }
        else {
          if (result["obj"]["modellist"].length > 0) {
            updatemdoel["modellist"] = that.data.modellist.concat(result["obj"]["modellist"]);
          }
        }
      }
      wx.stopPullDownRefresh();
      that.setData(updatemdoel);
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this
    this.getpagelist(that, -1)
  },

})